<template>
  <!--发票申请数据-->
  <div class="tuika">
    <div class="search">
      <input type="text" placeholder="搜索" v-model="queryContent">
      <img src="../../assets/search.png" alt="" width="16" @click="goSearch()">
    </div>
    <div class="page-infinite-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }">
      <wv-group
        v-infinite-scroll="getList"
        infinite-scroll-disabled="loading"
        infinite-scroll-distance="10"
      >
        <wv-tabs v-model="activeIndex" class="container" @click="goSearch()">
          <wv-tab title="全部">
            <!--1已提交,2取消提交,3退卡专员审核中,4退卡专员审核拒绝,5退卡专员审核通过,6退款专员专员审核中,7退款专员审核拒绝,8退款专员审核通过,9退款专员已退款,10财务经理审核拒绝,11财务经理审核通过-->
            <ul class="list">
              <li v-for="item in applyInvoiceList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.invoiceState==0">开票中</span>
                    <span class="status" v-if="item.invoiceState==1">已开票</span>
                  </li>
                  <li>
                    销售：<span>{{item.employeeName}}</span>
                  </li>
                  <li>
                    会员卡号：<span>{{item.vipCardNo}}</span>
                  </li>
                  <li>
                    <p>
                      <span>申请时间：{{item.createDate}}</span>
                    </p>
                    <!--<wv-button type="default" :mini="true" class="lookdetail" v-if="item.invoiceState==0" @click="goCancelTuika(item.backcardRecordId)">取消提交</wv-button>-->
                  </li>
                  <li>
                    <p>
                      <span>开票内容：{{item.invoiceRemark}}</span><br>
                    </p>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
          <wv-tab title="开票中">
            <ul class="list">
              <li v-for="item in applyInvoiceList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.invoiceState==0">开票中</span>
                    <span class="status" v-if="item.invoiceState==1">已开票</span>
                  </li>
                  <li>
                    销售：<span>{{item.employeeName}}</span>
                  </li>
                  <li>
                    会员卡号：<span>{{item.vipCardNo}}</span>
                  </li>
                  <li>
                    <p>
                      <span>申请时间：{{item.createDate}}</span>
                    </p>
                    <!--<wv-button type="default" :mini="true" class="lookdetail" v-if="item.invoiceState==0" @click="goCancelTuika(item.backcardRecordId)">取消提交</wv-button>-->
                  </li>
                  <li>
                    <p>
                      <span>开票内容：{{item.invoiceRemark}}</span><br>
                    </p>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
          <wv-tab title="已开票">
            <ul class="list">
              <li v-for="item in applyInvoiceList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.invoiceState==0">开票中</span>
                    <span class="status" v-if="item.invoiceState==1">已开票</span>
                  </li>
                  <li>
                    <p>
                      <span>申请时间：{{item.createDate}}</span>
                    </p>
                    <!-- <wv-button type="default" :mini="true" class="lookdetail" v-if="item.isCheck==1">取消提交</wv-button>-->
                  </li>
                  <li>
                    <p>
                      <span>开票内容：{{item.invoiceRemark}}</span><br>
                    </p>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
        </wv-tabs>
      </wv-group>
    </div>
    <router-link to="/invoicetijiao" tag="p" class="offer"><img src="../../assets/xinjian.png" alt="" width="18">新建
    </router-link>
  </div>
</template>

<script type="text/ecmascript-6">
  import {getInvoiceList, cancelTuika} from '../../../test/unit/http'
  import {Toast} from 'we-vue'

  export default {
    name: 'invoice',
    props: {},
    data() {
      return {
        activeIndex: 0,
        applyInvoiceList: [],
        queryContent: '',
        wrapperHeight: 0,
        page: 1,
        rows: 10,
        loading: false,
        pages: 0,
        totalNum: 0
      };
    },
    methods: {
      goSearch() {
        this.applyInvoiceList = [];
        this.page = 1;
        this.getList();
      },
      getData(params) {
        this.loading = true;
        getInvoiceList(params).then(res => {
          console.log(res);
          if (res.code == 100) {
            let data = res.object;
            let list = data.rows;
            let pages = data.pages;
            let page = data.page;
            this.page = page;
            this.pages = pages;
            let totalNum = data.totalNum;
            this.totalNum = totalNum;
            if (list.length > 0) {
              this.applyInvoiceList = this.applyInvoiceList.concat(list);
            }
            if (this.page < this.pages) {
              this.page++;
              this.loading = false
            } else {
              this.loading = true
            }
          } else {
            Toast.text(res.info);
          }
        })
      },
      getList() {
        let params = {};
        let activeIndex = this.activeIndex;
        if (activeIndex == 1) {
          params['invoiceState'] = 0;
        }
        if (activeIndex == 2) {
          params['invoiceState'] = 1;
        }
        params['page'] = this.page;
        params['rows'] = this.rows;
        params['queryContent'] = this.queryContent;
        this.getData(params)
      }
    },
    created() {
    },
    components: {}
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .search {
    position: relative;
    width: 95%;
    margin: 10px auto;

    input {
      width: 90%;
      border: 1px solid #eee;
      box-shadow: 0 3px 4px rgba(17, 17, 17, 0.05);
      border-radius: 7px;
      height: 25px;
      line-height: 25px;
      padding: 10px;
      color: #111;
    }

    img {
      position: absolute;
      right: 20px;
      top: 16px;
    }
  }

  .list {
    padding-bottom: 70px;

    > li {
      margin: 15px 10px;
      text-align: left;
      border-bottom: 1px solid #ddd;

      li {
        margin-bottom: 10px;
      }

      li:first-child {
        font-size: 16px;
        color: #111;
        font-weight: 700;

        span {
          color: #999;
          margin-left: 10px;
        }

        .status {
          font-size: 13px;
          float: right;
          font-weight: normal;
        }
      }

      li:nth-child(2) {
        font-size: 14px;
        color: #111;
        display: flex;
        text-align: left;
      }

      li:nth-child(3) {
        font-size: 14px;
        color: #111;
        display: flex;
        text-align: left;
      }

      li:nth-child(4) {
        font-size: 14px;
        color: #111;
        display: flex;
        text-align: left;
      }

      li:last-child {
        font-size: 13px;
        color: #4b4b4b;
        font-weight: 700;
      }
    }

    > li:last-child {
      border-bottom: none;
    }

  }

  .offer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: #f98e3c;
    height: 50px;
    line-height: 50px;
    color: #fff;

    img {
      vertical-align: middle;
      margin-right: 5px;
    }
  }
</style>
